<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width" />
    <title>菜鸟教程</title>
  </head>
  <body>
    <script type="text/javascript">
      console.log("立即执行函数");

      // function(a,b){
      //   console.log("a="+a);
      //   console.log("b="+b);
      // }

      (function (a, b) {
        console.log("a=" + a);
        console.log("b=" + b);
      })(123, 456);

      var arr = [];
      for (var i = 0; i < 5; i++) {
        (function (i) {
          arr.push(function () {
            console.log(i);
          });
        })(i);
      }
      arr[2]();
    </script>
  </body>
</html>
